/**
 * @author lwlianghehe@gmail.com
 * @date 2024/11/22
 */
import XTreeXml from "./XTreeXml.ts";
import DownXml from "./DownXml.ts";
import TreeXml from "./TreeXml.ts";
import ReportXml from "./ReportXml.ts";
import HeaderXML from "./HeaderXML.ts";
import { ParserField } from "./model/ParserField.ts";
import Form from "../model/form/Form.ts";
import { ViewModeEnum } from "./model/types.ts";


export interface XMLParserResult {
    viewMode: ViewModeEnum;
    fields: ParserField[]
    fullFields: ParserField[],
    one2ManyFields?: string[],
    kanban: any,
    tree: TreeXml,
    form: Form,
    search: any,
    xtree: XTreeXml,
    header: HeaderXML,
    down: DownXml,
    report: ReportXml
}

export function getTemplate(parseResult: XMLParserResult) {
    if (parseResult.viewMode === 'kanban') {
        return parseResult.kanban.template
    }
    if (parseResult.viewMode === 'form') {
        return parseResult.form.template
    }
    if (parseResult.viewMode === 'search') {
        return parseResult.search.template
    }
    if (parseResult.viewMode === 'xtree') {
        return parseResult.xtree.template
    }
    if (parseResult.viewMode === 'down') {
        return parseResult.down.template
    }
    if (parseResult.viewMode === 'tree') {
        return parseResult.tree.template
    }
    if (parseResult.viewMode === 'report') {
        return parseResult.report.template
    }
    return ""
}